package com.itrus.util;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public class XMLUtils
{
  public static void appendAttribute(Document paramDocument, Element paramElement, String paramString1, String paramString2)
  {
    Attr localAttr = paramDocument.createAttribute(paramString1);
    localAttr.setNodeValue(paramString2);
    paramElement.setAttributeNode(localAttr);
  }

  public static Element appendMixedNode(Document paramDocument, Element paramElement, String paramString1, String paramString2)
  {
    Element localElement = paramDocument.createElement(paramString1);
    localElement.appendChild(paramDocument.createTextNode(paramString2));
    paramElement.appendChild(localElement);
    return localElement;
  }

  public static Element appendNode(Document paramDocument, Element paramElement, String paramString)
  {
    Element localElement = paramDocument.createElement(paramString);
    paramElement.appendChild(localElement);
    return localElement;
  }

  public static Document createDocument()
    throws ParserConfigurationException
  {
    return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  }

  public static Document createDocumentFromXML(String paramString)
    throws ParserConfigurationException, SAXException, IOException
  {
    return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(paramString.getBytes()));
  }

  public static Document createDocumentFromXMLFile(String paramString)
    throws ParserConfigurationException, SAXException, IOException
  {
    return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(paramString);
  }

  public static Element createRootNode(Document paramDocument, String paramString)
  {
    Element localElement = paramDocument.createElement(paramString);
    paramDocument.appendChild(localElement);
    return localElement;
  }

  public static String transformToXML(Document paramDocument, String paramString)
    throws TransformerException
  {
    Transformer localTransformer = TransformerFactory.newInstance().newTransformer();
    DOMSource localDOMSource = new DOMSource(paramDocument);
    localTransformer.setOutputProperty("encoding", paramString);
    StringWriter localStringWriter = new StringWriter();
    localTransformer.transform(localDOMSource, new StreamResult(localStringWriter));
    return localStringWriter.getBuffer().toString();
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.itrus.util.XMLUtils
 * JD-Core Version:    0.6.2
 */